using System;
using System.Collections.Generic;
using System.Xml;
using Mbs.Services;

namespace Mbs
{
    /// <summary>
    /// 
    /// </summary>
    public interface IServiceLocator : IServiceProvider, IServiceRegistry,IDisposable
    {
        /// <summary>
        /// 
        /// </summary>
        IServiceLocator Root { get; }

        /// <summary>
        /// 
        /// </summary>
        bool IsRoot { get; }

        /// <summary>
        /// 
        /// </summary>
        IServiceLocator Parent { get; }

        /// <summary>
        /// 
        /// </summary>
        IClassLoader ClassLoader { get; }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="child"></param>
        void RemoveChildLocator(IServiceLocator child);

        /// <summary>
        /// 
        /// </summary>
        IEnumerable<IServiceLocator> Childs { get; }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        object Get(string id);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="serviceType"></param>
        /// <returns></returns>
        object Get(Type serviceType);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="serviceType"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        object Get(Type serviceType, string id);

        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="TService"></typeparam>
        /// <returns></returns>
        TService Get<TService>();

        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="TService"></typeparam>
        /// <param name="id"></param>
        /// <returns></returns>
        TService Get<TService>(string id);
    }

    //public enum LifestyleType
    //{

    //    Undefined,
    //    Singleton,
    //    Thread,
    //    Transient,
    //    Pooled,
    //    Custom,
    //    PerWebRequest
    //}

    //[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
    //public class ComponentAttribute : LifestyleAttribute
    //{
       
    //    public Type Service { get; set; }


    //    public String Key { get; set; }
    //}

    //[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
    //public abstract class LifestyleAttribute : Attribute
    //{
    //    public LifestyleAttribute():this(LifestyleType.Singleton) { }
    //    protected LifestyleAttribute(LifestyleType type)
    //    {
    //        Lifestyle = type;
    //    }
    //    public LifestyleType Lifestyle { get; set; }
    //}

    //[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
    //public sealed class SingletonAttribute : LifestyleAttribute
    //{
    //    public SingletonAttribute()
    //        : base(LifestyleType.Singleton)
    //    {
    //    }
    //}

    //[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
    //public sealed class TransientAttribute : LifestyleAttribute
    //{
    //    public TransientAttribute()
    //        : base(LifestyleType.Transient)
    //    {
    //    }
    //}

    //[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
    //public sealed class PerThreadAttribute : LifestyleAttribute
    //{
    //    public PerThreadAttribute()
    //        : base(LifestyleType.Thread)
    //    {
    //    }
    //}

    //[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
    //public sealed class PerWebRequestAttribute : LifestyleAttribute
    //{
    //    public PerWebRequestAttribute()
    //        : base(LifestyleType.PerWebRequest)
    //    {
    //    }
    //}

    //[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
    //public sealed class PooledAttribute : LifestyleAttribute
    //{
    //    private static readonly int Initial_PoolSize = 5;
    //    private static readonly int Max_PoolSize = 15;

    //    private readonly int initialPoolSize;
    //    private readonly int maxPoolSize;

    //    public PooledAttribute()
    //        : this(Initial_PoolSize, Max_PoolSize)
    //    {
    //    }

    //    public PooledAttribute(int initialPoolSize, int maxPoolSize)
    //        : base(LifestyleType.Pooled)
    //    {
    //        this.initialPoolSize = initialPoolSize;
    //        this.maxPoolSize = maxPoolSize;
    //    }

    //    public int InitialPoolSize
    //    {
    //        get { return initialPoolSize; }
    //    }

    //    public int MaxPoolSize
    //    {
    //        get { return maxPoolSize; }
    //    }
    //}
}
